import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'logger_level.dart';
import 'zendesk_plugin_platform_interface.dart';

/// An implementation of [ZendeskPluginPlatform] that uses method channels.
class MethodChannelZendeskPlugin extends ZendeskPluginPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('zendesk_plugin');

  @override
  Future<bool?> initZendeskSDK({required String zendeskIdentifier}) async {
    final result = await methodChannel.invokeMethod<bool>(
      'initZendeskSDK',
      zendeskIdentifier,
    );
    return result;
  }

  @override
  Future<bool?> pushToConversation() async {
    final result = await methodChannel.invokeMethod<bool>('pushToConversation');
    return result;
  }

  @override
  Future<int?> getUnreadCount() async {
    final count = await methodChannel.invokeMethod<int>('getUnreadCount');
    return count;
  }

  @override
  Future<bool?> setLoggerEnabled(bool enabled) async {
    final result = await methodChannel.invokeMethod<bool>(
      'setLoggerEnabled',
      enabled,
    );
    return result;
  }

  @override
  Future<bool?> setLoggerLevel({
    required ZendeskLoggerLevel level,
  }) async {
    final result = await methodChannel.invokeMethod<bool>(
      'setLoggerLevel',
      level.value,
    );
    return result;
  }
}
